package commons.base.groovy;

import groovy.lang.GroovyShell;

public class GroovyDemo1 {

	public static void main(String[] args) throws Exception{
		GroovyShell groovyShell = new GroovyShell();
		
		groovyShell.setVariable("a", 111);
		Object result = groovyShell.evaluate("return ['id':1,'name':2,'age':3]");
		
		System.err.println(result.getClass().getName());
		
//		groovyShell.resetLoadedClasses();
		
		
//		ScriptEngine engine = new ScriptEngineManager().getEngineByName("groovy");
//		engine.put("a", 111);
//		Object result2 = engine.eval("return ['id':1,'name':2,'age':3]");
//		System.err.println(result2.getClass().getName());
	}
	
	public static Object eval(String script){
		GroovyShell groovyShell = new GroovyShell();
		return groovyShell.evaluate(script);
	}

}
